<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('车辆信息列表')" />
</head>
<style>
    .select-list li p, .select-list li label:not(.radio-box){
        width: 91px;
    }
</style>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>车牌号码：</label>
                                <input type="text" name="carNum"/>
                            </li>
                            <li>
                                <label>号牌种类：</label>
                                <select name="carNumType" th:with="type=${@dict.getType('car_num_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>车辆状态：</label>
                                <select name="carState" th:with="type=${@dict.getType('car_state')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>车辆类型：</label>
                                <select name="carType" th:with="type=${@dict.getType('car_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>车身颜色：</label>
                                <input type="text" name="carColour"/>
                            </li>
                            <li>
                                <label>机动车所有人：</label>
                                <input type="text" name="carOwner"/>
                            </li>
                            <li>
                                <label>最近定验日期：</label>
                                <input type="text" class="time-input" placeholder="请选择最近定验日期" name="latestCheckDate"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="car:car:add">
                    <i class="fa fa-plus"></i> 添加车辆
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="car:car:edit">
                    <i class="fa fa-edit"></i> 修改车辆
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="car:car:remove">
                    <i class="fa fa-remove"></i> 删除车辆
                </a>
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="car:car:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('car:car:edit')}]];
        var removeFlag = [[${@permission.hasPermi('car:car:remove')}]];
        var carNumTypeDatas = [[${@dict.getType('car_num_type')}]];
        var carStateDatas = [[${@dict.getType('car_state')}]];
        var carTypeDatas = [[${@dict.getType('car_type')}]];
        var prefix = ctx + "car/car";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "车辆信息",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'carId',
                    title: '车辆ID',
                    visible: false
                },
                {
                    field: 'carNum',
                    title: '车牌号码'
                },
                {
                    field: 'carNumType',
                    title: '号牌种类',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(carNumTypeDatas, value);
                    }
                },
                {
                    field: 'carNumColour',
                    title: '号牌颜色'
                },
                {
                    field: 'carModel',
                    title: '车辆型号',
                    visible: false
                },
                {
                    field: 'carState',
                    title: '车辆状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(carStateDatas, value);
                    }
                },
                {
                    field: 'carEngineNum',
                    title: '发动机号'
                },
                {
                    field: 'carType',
                    title: '车辆类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(carTypeDatas, value);
                    }
                },
                {
                    field: 'carColour',
                    title: '车身颜色'
                },
                {
                    field: 'carOwner',
                    title: '机动车所有人'
                },
                {
                    field: 'carBrand',
                    title: '车辆品牌'
                },
                {
                    field: 'ownerNum',
                    title: '身份证号码',
                    visible: false
                },
                {
                    field: 'ownerName',
                    title: '身份证明名称',
                    visible: false
                },
                {
                    field: 'accidentsNum',
                    title: '事故次数'
                },
                {
                    field: 'violationsNum',
                    title: '违法次数'
                },
                {
                    field: 'latestCheckDate',
                    title: '最近定验日期'
                },
                {
                    field: 'remark',
                    title: '备注',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.carId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.carId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>